import { fromJS } from 'immutable'
import sessionStore from '@/utils/store'
import * as types from '@/typings/userType'

export default {
  [types.USER_LOGIN_USER](state, { token, nickname }) {
    sessionStore().set('token', token)
    sessionStore().set('nickname', nickname)

    return state.set('token', token).set('nickname', nickname)
  },
  [types.USER_INIT_LOGIN_USER](state, { token, nickname }) {
    return state.set('token', token).set('nickname', nickname)
  },
  [types.USER_LOGINOUT_USER](state, data) {
    sessionStore().remove('token')
    sessionStore().remove('nickname')
    return state.set('token', '').set('nickname', '')
  },
}